/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package clusteranalyst2;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
/**
 *
 * @author jlh
 */
public class PrintMethods {
    public static  void printArrayList(ArrayList al)
    {
        Iterator it=al.iterator();
        while(it.hasNext())
        {
            Object obj=it.next();
            double[] resultRow=(double[])obj;

            for( int i=0;i<resultRow.length;i++)
            {
                System.out.println(resultRow[i]);
            }
             System.out.println("##############");
        }
    }
    public static void printMatrix(double [][] matrix)
    {
        int jLenth=matrix[0].length;
        for(int i=0;i<matrix.length;i++)
        {
            for(int j=0;j<jLenth;j++)
            {
                System.out.print(matrix[i][j]+"  ");
            }
            System.out.print("\n");
        }
    }
    public static void printTriangular(double [][] matrix)
    {
         int jLenth=matrix[0].length;
        for(int i=0;i<matrix.length;i++)
        {
            for(int j=0;j<jLenth;j++)
            {
                if(i>=j)
                {
                    System.out.print(matrix[i][j]+"  ");
                }
                else
                {
                    System.out.print("  ");
                }
                
            }
            System.out.print("\n");
        }

    }
    public static void printArray(double [] a)
    {
        for(int i=0;i<a.length;i++)
        {
            System.out.print(a[i]+"  ");
        }
    }

    //////////////////聚类分析部分//////////////////////
    public  static void printHashMap(HashMap hm)
    {        
        Set entry=hm.entrySet();
        Iterator it=entry.iterator();
        while(it.hasNext())
        {
           Map.Entry me=(Map.Entry)it.next();
           double [] a=(double[])(me.getValue());

           for(int j=0;j<a.length;j++)
            {               
              System.out.print(a[j]+"  ");                 
            }
           System.out.print("\n");          
        }
    }
    //只用于打印重构后的矩阵
     public  static void printTrailHashMap(HashMap hm)
    {
        int count=0;      
        Set entry=hm.entrySet();
        Iterator it=entry.iterator();       
        while(it.hasNext())
        {
           Map.Entry me=(Map.Entry)it.next();
           double [] a=(double[])(me.getValue());

           for(int j=0;j<a.length;j++)
            {
                 if(count>=j)
                    {
                          System.out.print(a[j]+"  ");
                    }
                 else
                 {
                     continue;
                 }
            }
           System.out.print("\n");
           count++;
        }
    }


}
